package com.whfc.common.enums;

import org.springframework.util.Assert;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/7/22 11:47
 */
public enum AppType {

    JJC(1, "智慧工地小程序"),

    GJY(2, "工机云小程序"),

    CMS(3, "后台"),

    FMAM(4, "物资小程序"),

    HHF(5, "环焊缝"),

    FVS(6, "视频监控小程序"),

    EQUIP(7, "考勤设备小程序"),

    TXBDS(8, "天星工程卫士"),

    EMP(9, "人员管理小程序"),

    REJ(10, "融E建"),

    QYGS(11, "丘砚高速"),

    FCWL(12, "风潮物联服务号"),

    TEST(13, "测试服务号"),

    SGITG(14, "国网信通E装备"),

    ZQFACE(15, "掌勤科技"),

    GZHONYO(16, "云点睿控"),

    MIDUO(17, "米多智慧"),

    LXK(18, "龙溪口智慧工地"),

    KQ(19, "考勤小程序")

    ;

    private Integer value;

    private String desc;

    AppType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer value() {
        return value;
    }

    /**
     * 解析应用类型
     *
     * @param value
     * @return
     */
    public static AppType parseByValue(Integer value) {

        AppType[] appTypes = AppType.values();
        for (AppType appType : appTypes) {
            if (appType.value.equals(value)) {
                return appType;
            }
        }
        return JJC;
    }

    public static AppType parseByName(String name) {
        AppType[] appTypes = AppType.values();
        for (AppType appType : appTypes) {
            if (appType.name().equalsIgnoreCase(name)) {
                return appType;
            }
        }
        return JJC;
    }

    public static void main(String[] args) {
        AppType[] appTypes = AppType.values();
        for (AppType appType : appTypes) {
            System.out.println(appType.name() + "=" + appType.value);
            Assert.isTrue(appType == AppType.parseByValue(appType.value), "11111111111");
            Assert.isTrue(appType == AppType.parseByName(appType.name()), "2222222222");
        }

    }
}
